package com.aaa.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * spring mvc 配置类
 */
@Configuration
public class MyMVCConfig implements WebMvcConfigurer {


    //图片映射
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/picture/**")
                .addResourceLocations("file:E:/project_3_vue2/picture/");
    }

    //跨域配置
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        //registry.对于那些路径.允许哪些项目的访问.允许接收跨域的cookie
        registry.addMapping("/**").allowedOrigins("*").allowCredentials(true);
    }
}
